#include<bits/stdc++.h>
using namespace std;
//open long long remember
#define ll long long
const long long maxn=1e5+10;
const long long maxl=1e6+10;
long long n,m,L,V,ans1,ans2,d[maxn],v[maxn],a[maxn],p[maxn],cnt[maxl],sum[maxl],T,np,sml[maxl];
struct Node
{
    long long l,r,vis;
}s[maxn];
bool cmp(Node x,Node y)
{
    return x.r<y.r;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>L>>V;
        memset(cnt,0,sizeof(cnt));
        ans1=0,ans2=0;
        for(int i=1;i<=n;i++)
        {
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
            cnt[p[i]]++;
        }
       // sort(p+1,p+m+1);
        sum[0]=cnt[0];sml[0]=0;
        for(int i=1;i<=L;i++)
        {
            sum[i]=sum[i-1]+cnt[i];
            if(cnt[i]>0) sml[i]=i;
            else sml[i]=sml[i-1];
        }
        for(int i=1;i<=n;i++)//l[i]+1~r[i] can detect
        {
            if(v[i]<=V&&a[i]<=0)
            {
                s[i].l=0;
                s[i].r=0;
                s[i].vis=1;
            }

            else if(v[i]>V&&a[i]>=0)
            {
                s[i].l=d[i]-1;
                s[i].r=L;
                if(sum[L]-sum[s[i].l]>0)
                {
                    ans1++;
                    s[i].vis=0;
                }
                else s[i].vis=1;
            }
            else if(v[i]<=V&&a[i]>0)
            {
                s[i].l=min(L,d[i]+(V*V-v[i]*v[i])/(2*a[i]));
                s[i].r=L;
                if(sum[L]-sum[s[i].l]>0){
                    ans1++;
                    s[i].vis=0;
                }
                else s[i].vis=1;
            }
            else if(v[i]>V&&a[i]<0)
            {
                s[i].r=min(L,d[i]+(v[i]*v[i]-V*V)/(-2*a[i]));
                s[i].l=d[i]-1;
                if(sum[s[i].r]-sum[s[i].l]>0){
                    ans1++;
                    s[i].vis=0;
                }
                else s[i].vis=1;
            }
        }
        sort(s+1,s+n+1,cmp);

        np=-1;
        //for(int i=1;i<=n;i++)
        //{
        //    cout<<i<<":"<<s[i].l<<' '<<s[i].r<<endl;
        //}
        for(int i=1;i<=n;i++)
        {
            if(s[i].vis==1)
            {
                continue;
            }
            if(s[i].l<np)
            {
                continue;
            }
            else
            {
                np=sml[s[i].r];
                ans2++;
                //cout<<i<<' '<<np<<endl;
            }
        }
        cout<<ans1<<' '<<m-ans2<<endl;
    }
    return 0;
}
